<?php

use App\Http\Controllers\AttachmentController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\CatController;
use App\Http\Controllers\CodeController;
use App\Http\Controllers\CommentController;
use App\Http\Controllers\ConfigController;
use App\Http\Controllers\FavoriteController;
use App\Http\Controllers\TopicController;
use App\Http\Controllers\UserController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

//Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
//    return $request->user();
//});

Route::post('send/code',[CodeController::class,'send']);
Route::post('send/repassword_code',[CodeController::class,'repassword_send']);
Route::put('auth/repassword',[AuthController::class,'repassword']);
Route::post('auth/login',[AuthController::class,'login']);
Route::post('auth/register',[AuthController::class,'register']);
Route::post('upload/image',[AttachmentController::class,'image']);

Route::get('get_one_user_favorite_topics',[FavoriteController::class,'getOneUserFavoriteTopics']);
Route::get('is_favorite/{user}/{topic}',[FavoriteController::class,'is_favorite']);
Route::get('favorite/toggle/{topic}',[FavoriteController::class,'toggle']);

Route::post('cat/change_sort',[CatController::class,'changeSort']);
Route::apiResource('cat',CatController::class);

Route::get('per_cat/{c_id}',[TopicController::class,'per_cat']);
Route::get('get_one_user_topics',[TopicController::class,'get_one_user_topics']);
Route::apiResource('topic',TopicController::class);

Route::get('get_all_comments',[CommentController::class,'all_comments']);
Route::get('get_one_user_comments',[CommentController::class,'get_one_user_comments']);
Route::post('comment/{topic}',[CommentController::class,'store']);
Route::post('reply/comment/{topic}/{comment}',[CommentController::class,'replayComment']);
Route::get('list/comment/{topic}',[CommentController::class,'index']);
Route::delete('comment/{comment}',[CommentController::class,'destroy']);

Route::put('user_freeze/{user}',[UserController::class,'freeze']);
Route::delete('user_del/{user}',[UserController::class,'destroy']);
Route::get('get_users',[UserController::class,'get_users']);
Route::get('user/{user}',[UserController::class,'show']);
Route::get('get_current_user',[UserController::class,'get_current_user']);
Route::put('update_current_user',[UserController::class,'update_current_user']);
Route::put('update_current_user_nick',[UserController::class,'update_current_user_nick']);
Route::post('logout',[UserController::class,'logout']);

Route::put('config/{fieldName}',[ConfigController::class,'update']);

Route::get('get_config/{fieldName}',[ConfigController::class,'get_config']);


